import time
import unittest
from selenium import webdriver
from ddt import ddt, data, unpack, file_data
# import PyYAML


# # 创建
@ddt
class TestDemo(unittest.TestCase):
    # 前置条件
    @classmethod
    def setUpClass(cls) -> None:
        cls.driver = webdriver.Chrome()
        cls.driver.get("https://www.baidu.com")
#
#     # 后置条件
#     def tearDown(self) -> None:
#         self.driver.quit()
#
#     # 类的初始化
#     @classmethod
#     def setUpClass(cls) -> None:
#         print("setupclass")
#     # 类的释放
#     @classmethod
#     def tearDownClass(cls) -> None:
#         print("teardownclass")
    # 测试用例
    @data("张三", "李四")
    # @unpack
    def test_demo01(self, text):

        self.driver.find_element_by_id('kw').send_keys(text)
        self.driver.find_element_by_id('su').click()

#
#     @file_data("test.json")
#     def test_demo02(self, **user):
#         url = user.get("url")
#         text = user.get("username")
#         self.driver.get(url)
#         self.driver.find_element_by_id('kw').send_keys(text)
#         self.driver.find_element_by_id('su').click()
#         time.sleep(5)




    # def test_demo02(self):
    #     self.driver.get("http://www.baidu.com")
    #     self.driver.find_element_by_id('kw').send_keys("张三")
    #     self.driver.find_element_by_id('su').click()
    #     time.sleep(5)



if __name__ == '__main__':
    unittest.main()


# tmp = "a", "b"
#
# def test(*tmp):
#     print(tmp[1])
#
# test(tmp)
#
# import csv
#
# with open("User/answer.csv", "r") as a:
#     reader = csv.reader(a)
#
#     for i in reader:
#         print(type(i))